< previous page page_389 next page >

Page 389
3. Select a new class when prompted.
4. Press F4 to bring up the Properties window if its not already docked in the design environment.
5. Set the Name property to Employee. Just ignore the other properties for now.
6. Add four Private data variables to the CLS file in the General Declarations area by typing in the following code:
Option Explicit
Private mlngEmpID As Long
Private mstrFirstName As String
Private mstrLastName As String
Private mcurSalary As Currency
analysis.gifBecause youve created these variables as private module-level variables, no other routines outside of this class module will be able to read and write to these private variables. Obviously, one of the reasons to create an object is to allow other modules the ability to read and write to the properties of that object.

Reading Properties
After creating the private variables, you need to allow other modules in the project to read this private data. To accomplish this, you add multiple Property Get procedures to the class module.
EXERCISE
Adding Property Get Procedures
1. Add the following Property Get procedures to the Employee class:
Property Get EmpID() As Long
EmpID = mlngEmpID
End Property

Property Get FirstName() As String
FirstName = mstrFirstName
End Property

 
< previous page page_389 next page >

If you like this book, buy it!